package cn.wlinker.video.monitor.brand.hikversion.create.net.enums;

import cn.wlinker.video.monitor.brand.hikversion.create.net.HCNetSDK;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Optional;

@Getter
@AllArgsConstructor
public enum HCPlayControlEnum {
    //操作命令;0-上，1-下，2-左，3-右，4-左上，5-左下，6-右上，7-右下，8-放大，9-缩小，10-近焦距，11-远焦距
    ZOOM_IN(HCNetSDK.ZOOM_IN, "焦距变大", 11),
    ZOOM_OUT(HCNetSDK.ZOOM_OUT, "焦距变小", 10),
    FOCUS_NEAR(HCNetSDK.FOCUS_NEAR, "焦点前调", 8),
    FOCUS_FAR(HCNetSDK.FOCUS_FAR, "焦点后调", 9),
    IRIS_OPEN(HCNetSDK.IRIS_OPEN, "光圈扩大"),
    IRIS_CLOSE(HCNetSDK.IRIS_CLOSE, "光圈缩小"),
    TILT_UP(HCNetSDK.TILT_UP, "云台上仰", 0),
    TILT_DOWN(HCNetSDK.TILT_DOWN, "云台下俯", 1),
    PAN_LEFT(HCNetSDK.PAN_LEFT, "云台左转", 2),
    PAN_RIGHT(HCNetSDK.PAN_RIGHT, "云台右转", 3),
    UP_LEFT(HCNetSDK.UP_LEFT, "云台上仰和左转", 4),
    UP_RIGHT(HCNetSDK.UP_RIGHT, "云台上仰和右转", 6),
    DOWN_LEFT(HCNetSDK.DOWN_LEFT, "云台下俯和左转", 5),
    DOWN_RIGHT(HCNetSDK.DOWN_RIGHT, "云台下俯和右转", 7);

    private final Integer code;
    private final String msg;

    private Integer value;

    HCPlayControlEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static Optional<HCPlayControlEnum> getByValue(Integer direction) {
        HCPlayControlEnum[] values = HCPlayControlEnum.values();
        for (HCPlayControlEnum hcPlayControlEnum : values) {
            Integer currentValue = hcPlayControlEnum.getValue();
            if (direction.equals(currentValue)) {
                return Optional.of(hcPlayControlEnum);
            }
        }
        return Optional.empty();
    }
}
